package com.bsfcs.rag.entity;

import com.bsfcs.rag.enums.ContractCategory;
import com.bsfcs.rag.enums.ProcurementMethod;
import com.bsfcs.rag.utils.CacheUtils;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.Setter;

import java.math.BigDecimal;

@Data
@Entity
@Table(name = "htglxtcontract")
public class Contract {

    public Contract() {}

    public Contract(String id, String project, String cbxm_code, String cbxm_name, String code, String name, String opposite_contract_code, BigDecimal contract_total_money, String signing_time, String begintime, String endtime, String jsfsname, String kxytname, String contract_biz_status, String cgfs_type, String purchase_enabled, BigDecimal yj_income, BigDecimal yj_cost, BigDecimal yj_ml, BigDecimal gross_margin, BigDecimal net_profit_margin, BigDecimal yj_jl, BigDecimal jhtje, String client_name, String khxz, String szhy, String scale, String sf, String city_proper, String district_level, String address, String contracting_party_orgname, String signatory_id, String isauthorized, String consortium_type, String consortium_name, String legal_representative, String isconsortium) {
        this.id = id;
        this.project = project;
        this.cbxm_code = cbxm_code;
        this.cbxm_name = cbxm_name;
        this.code = code;
        this.name = name;
        this.opposite_contract_code = opposite_contract_code;
        this.contract_total_money = contract_total_money;
        this.signing_time = signing_time;
        this.begintime = begintime;
        this.endtime = endtime;
        this.jsfsname = jsfsname;
        this.kxytname = kxytname;
        this.contract_biz_status = ContractCategory.fromCode(contract_biz_status).getDisplayName();
        this.cgfs_type = ProcurementMethod.fromCode(cgfs_type).getName();
        this.purchase_enabled = "1".equals(purchase_enabled) ? "采购" : "投标";
        this.yj_income = yj_income;
        this.yj_cost = yj_cost;
        this.yj_ml = yj_ml;
        this.gross_margin = gross_margin;
        this.net_profit_margin = net_profit_margin;
        this.yj_jl = yj_jl;
        this.jhtje = jhtje;
        this.client_name = client_name;
        this.khxz = khxz;
        this.szhy = szhy == null ? "" : CacheUtils.getIndustry(szhy).getHy_name();
        this.scale = scale;
        this.sf = sf;
        this.city_proper = city_proper;
        this.district_level = district_level;
        this.address = address;
        this.contracting_party_orgname = contracting_party_orgname;
        this.signatory_id = signatory_id;
        this.isauthorized = isauthorized;
        this.consortium_type = consortium_type;
        this.consortium_name = consortium_name;
        this.legal_representative = legal_representative;
        this.isconsortium = isconsortium;
    }

    @Id
    @Column(name = "id")
    private String id;

    /**
     * 项目Id
     */
    @Column(name = "project")
    private String project;
    /**
     * 储备项目编号
     */
    @Column(name = "cbxm_code")
    private String cbxm_code;
    /**
     * 储备项目名称
     */
    @Column(name = "cbxm_name")
    private String cbxm_name;
    /**
     * 合同编号
     */
    @Column(name = "code")
    private String code;
    /**
     * 合同名称
     */
    @Column(name = "name")
    private String name;
    /**
     * 相对方合同编号
     */
    @Column(name = "opposite_contract_code")
    private String opposite_contract_code;
    @Column(name = "contract_total_money")
    private BigDecimal contract_total_money;

    /**
     * 签约时间
     */
    @Column(name = "signing_time")
    private String signing_time;

    /**
     * 开始时间
     */
    @Column(name = "begintime")
    private String begintime;

    /**
     * 结束时间
     */
    @Column(name = "endtime")
    private String endtime;

    /**
     * 结算方式
     */
    @Column(name = "jsfsname")
    private String jsfsname;

    /**
     * 款项用途
     */
    @Column(name = "kxytname")
    private String kxytname;

    /**
     * 合同类别
     */
    @Column(name = "contract_biz_status")
    private String contract_biz_status;

    /**
     * 采购方式
     */
    @Column(name = "cgfs_type")
    private String cgfs_type;

    /**
     * 招投标方式
     */
    @Column(name = "purchase_enabled")
    private String purchase_enabled;

    /**
     * 合同预计收入
     */
    @Column(name = "yj_income")
    private BigDecimal yj_income;

    /**
     * 合同预计成本
     */
    @Column(name = "yj_cost")
    private BigDecimal yj_cost;

    /**
     * 合同预计毛利
     */
    @Column(name = "yj_ml")
    private BigDecimal yj_ml;

    /**
     * 毛利率
     */
    @Column(name = "gross_margin")
    private BigDecimal gross_margin;

    /**
     * 净利率
     */
    @Column(name = "net_profit_margin")
    private BigDecimal net_profit_margin;
    /**
     * 合同预计净利
     */
    @Column(name = "yj_jl")
    private BigDecimal yj_jl;
    /**
     * 净合同金额
     */
    @Column(name = "jhtje")
    private BigDecimal jhtje;

    /**
     * 相对方名称
     */
    @Column(name = "client_name")
    private String client_name;
    /**
     * 相对方类型
     */
    @Column(name = "khxz")
    private String khxz;
    /**
     * 行业名称
     */
    @Column(name = "szhy")
    private String szhy;
    /**
     * 规模
     */
    @Column(name = "scale")
    private String scale;
    /**
     * 省份
     */
    @Column(name = "sf")
    private String sf;
    /**
     * 市区
     */
    @Column(name = "city_proper")
    private String city_proper;
    /**
     * 区级
     */
    @Column(name = "district_level")
    private String district_level;
    /**
     * 地址
     */
    @Column(name = "address")
    private String address;
    /**
     * 签约主体
     */
    @Column(name = "contracting_party_orgname")
    private String contracting_party_orgname;
    /**
     * 签约人
     */
    @Column(name = "signatory_id")
    private String signatory_id;
    /**
     * 签署授权
     */
    @Column(name = "isauthorized")
    private String isauthorized;
    /**
     * 联合体类型
     */
    @Column(name = "consortium_type")
    private String consortium_type;
    /**
     * 联合体名称
     */
    @Column(name = "consortium_name")
    private String consortium_name;
    /**
     * 法定代表人
     */
    @Column(name = "legal_representative")
    private String legal_representative;
    /**
     * 是否联合体
     */
    @Column(name = "isconsortium")
    private String isconsortium;
}
